﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Automobile.service.Model;
using Automobile.service.BLL;

namespace Automobile.service.UI
{
    public partial class WareHoseShow : System.Web.UI.Page
    {
        WareHoseBLL bll = new WareHoseBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WareHoseLoad();
                Session["count"] = bll.count();
            }
        }
        public void WareHoseLoad()
        {
            this.Repeater1.DataSource = bll.ShowWareHose();//获取数据源
            this.Repeater1.DataBind();//绑定数据源
            
        }

        protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string eName = e.CommandName;
            string WareHoseID = e.CommandArgument.ToString();
            switch (eName)
            {
                case "Del":
                    if (bll.Del(Convert.ToInt32(WareHoseID)) > 0)
                    {
                        Response.Write("<script>alert('删除成功！');</script>");
                        WareHoseLoad();
                    }
                    else
                    {
                        Response.Write("<script>alert('删除失败！');</script>");
                    }
                    break;
                case "Upt":
                    Response.Redirect("WareHoseEdit.aspx?id=" + WareHoseID);
                    break;
            }
        }

        protected void Unnamed_ServerClick(object sender, EventArgs e)
        {
            string WareHose_Name = this.WareHose_Name.Value;
            this.Repeater1.DataSource = bll.SearchWareHose(WareHose_Name);//获取数据源
            this.Repeater1.DataBind();//绑定数据源
        }
    }
}